home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / accessibility / nsAccessibleText.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  6KB  |  138 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: NPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public
  6.  * License Version 1.1 (the "License"); you may not use this file
  7.  * except in compliance with the License. You may obtain a copy of
  8.  * the License at http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS
  11.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  12.  * implied. See the License for the specific language governing
  13.  * rights and limitations under the License.
  14.  *
  15.  * The Original Code is mozilla.org code.
  16.  *
  17.  * The Initial Developer of the Original Code is Sun Microsystems, Inc.
  18.  * Portions created by Sun Microsystems are Copyright (C) 2002 Sun
  19.  * Microsystems, Inc. All Rights Reserved.
  20.  *
  21.  * Original Author: Kyle Yuan (kyle.yuan@sun.com)
  22.  *
  23.  * Contributor(s):
  24.  *
  25.  *
  26.  * Alternatively, the contents of this file may be used under the terms of
  27.  * either the GNU General Public License Version 2 or later (the "GPL"), or
  28.  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29.  * in which case the provisions of the GPL or the LGPL are applicable instead
  30.  * of those above. If you wish to allow use of your version of this file only
  31.  * under the terms of either the GPL or the LGPL, and not to allow others to
  32.  * use your version of this file under the terms of the NPL, indicate your
  33.  * decision by deleting the provisions above and replace them with the notice
  34.  * and other provisions required by the GPL or the LGPL. If you do not delete
  35.  * the provisions above, a recipient may use your version of this file under
  36.  * the terms of any one of the NPL, the GPL or the LGPL.
  37.  *
  38.  * ***** END LICENSE BLOCK ***** */
  39.  
  40. #ifndef _nsAccessibleText_H_
  41. #define _nsAccessibleText_H_
  42.  
  43. #include "nsAccessibleEventData.h"
  44. #include "nsBaseWidgetAccessible.h"
  45. #include "nsIAccessibleEditableText.h"
  46. #include "nsIAccessibleText.h"
  47. #include "nsIEditActionListener.h"
  48. #include "nsIEditor.h"
  49. #include "nsISelectionController.h"
  50. #include "nsITextControlFrame.h"
  51. #include "nsTextAccessibleWrap.h"
  52. #include "nsTextAccessible.h"
  53.  
  54. enum EGetTextType { eGetBefore=-1, eGetAt=0, eGetAfter=1 };
  55.  
  56. class nsAccessibleText : public nsIAccessibleText
  57. {
  58. public:
  59.   NS_DECL_ISUPPORTS
  60.   NS_DECL_NSIACCESSIBLETEXT
  61.  
  62.   nsAccessibleText(nsIDOMNode *aNode);
  63.   virtual ~nsAccessibleText() {};
  64.  
  65.   static PRBool gSuppressedNotifySelectionChanged;
  66.  
  67. protected:
  68.   nsCOMPtr<nsIDOMNode> mTextNode;
  69.  
  70.   virtual nsresult GetSelections(nsISelectionController **aSelCon, nsISelection **aDomSel);
  71.   nsresult GetTextHelperCore(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
  72.                              PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset,
  73.                              nsISelectionController *aSelCon, nsISelection *aDomSel,
  74.                              nsISupports *aClosure, nsAString & aText);
  75.   nsresult GetTextHelper(EGetTextType aType, nsAccessibleTextBoundary aBoundaryType,
  76.                          PRInt32 aOffset, PRInt32 *aStartOffset, PRInt32 *aEndOffset,
  77.                          nsISupports *aClosure, nsAString & aText);
  78.  
  79.   static nsresult DOMPointToOffset(nsISupports *aClosure, nsIDOMNode* aNode, PRInt32 aNodeOffset, PRInt32 *aResult);
  80.   static nsresult OffsetToDOMPoint(nsISupports *aClosure, PRInt32 aOffset, nsIDOMNode** aResult, PRInt32* aPosition);
  81.   static nsresult GetCurrectOffset(nsISupports *aClosure, nsISelection *aDomSel, PRInt32 *aOffset);
  82.  
  83.   friend class nsAccessibleHyperText;
  84. };
  85.  
  86. class nsAccessibleEditableText : public nsAccessibleText,
  87.                                  public nsIAccessibleEditableText,
  88.                                  public nsIEditActionListener
  89. {
  90. public:
  91.   NS_DECL_ISUPPORTS
  92.   NS_DECL_NSIACCESSIBLEEDITABLETEXT
  93.   NS_DECL_NSIEDITACTIONLISTENER
  94.  
  95.   nsAccessibleEditableText(nsIDOMNode *aNode);
  96.   virtual ~nsAccessibleEditableText() {};
  97.  
  98.   NS_IMETHOD GetCaretOffset(PRInt32 *aCaretOffset);
  99.   NS_IMETHOD SetCaretOffset(PRInt32 aCaretOffset);
  100.   NS_IMETHOD GetCharacterCount(PRInt32 *aCharacterCount);
  101.   NS_IMETHOD GetText(PRInt32 startOffset, PRInt32 endOffset, nsAString & aText);
  102.   NS_IMETHOD GetTextBeforeOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
  103.                                  PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
  104.   NS_IMETHOD GetTextAtOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
  105.                              PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
  106.   NS_IMETHOD GetTextAfterOffset(PRInt32 aOffset, nsAccessibleTextBoundary aBoundaryType,
  107.                                 PRInt32 *aStartOffset, PRInt32 *aEndOffset, nsAString & aText);
  108.  
  109.   void ShutdownEditor();
  110.  
  111.   static PRBool IsSingleLineTextControl(nsIDOMNode *aDomNode);
  112.  
  113. protected:
  114.   virtual nsresult GetSelections(nsISelectionController **aSelCon, nsISelection **aDomSel);
  115.  
  116.   void SetEditor(nsIEditor *aEditor);
  117.   nsITextControlFrame* GetTextFrame();
  118.   nsresult GetSelectionRange(PRInt32 *aStartPos, PRInt32 *aEndPos);
  119.   nsresult SetSelectionRange(PRInt32 aStartPos, PRInt32 aEndPos);
  120.   nsresult FireTextChangeEvent(AtkTextChange *aTextData);
  121.  
  122.   // To solve the naming conflict with nsDocAccessible::mEditor, we have to name it
  123.   // "mPlainEditor", though it's not necessary to be a "plaintext" editor.
  124.   nsCOMPtr<nsIEditor>  mPlainEditor;
  125. };
  126.  
  127. class nsTextAccessibleWrap : public nsTextAccessible,
  128.                              public nsAccessibleText
  129. {
  130. public:
  131.   NS_DECL_ISUPPORTS_INHERITED
  132.  
  133.   nsTextAccessibleWrap(nsIDOMNode* aDomNode, nsIWeakReference* aShell);
  134. };
  135.  
  136. #endif
  137.  
  138.